package org.hhchat.leetcode.dp;

/**
 * Created by HMH on 2017/3/31.
 * dp
 */
public class code198 {
    public static class Solution {
        public int rob(int[] nums) {
            int get = 0;
            int noget = 0;
            int best=0;
            for(int i = 0;i<nums.length;i++) {
                int tempnoget = get>noget?get:noget;
                int tempget = noget+nums[i];
                get = tempget;
                noget = tempnoget;
            }
            best = get > noget ? get : noget;
            return best;
        }
    }
    public static void main(String[] args){
        System.out.println(new Solution().rob(new int[]{2,1,1,6}));
    }
}
